Write a program that
a. Opens the data file noisedata.txt and reads the dc, gt, and snr values into arrays. (You must use the
exact file provided with the problem statement, including the text headings.)
Noisedata.txt
This data file is arranged as follows
The number on a lone line is the dopant concentration in atoms/cucm x 1.00E-17
The next five lines are the gt in nanometers
followed by the signal to noise ratio in decibels
1
2 35.1
2.2 36.3
2.4 37.2
2.6 38.1
2.8 39.5
1.2
2 37.2
2.2 39.5
2.4 41.2
2.6 42.3
2.8 46.2
1.4
2 41.2
2.2 44.2
2.4 48.2
2.6 50.3
2.8 53.4
1.6
2 48.2
2.2 51.2
2.4 55.6
2.6 60.2
2.8 65.2
1.8
2 55.6
2.2 62.3
2.4 66.2
2.6 72.5
2.8 78.6
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main (void)
{
printf("\nLinear Regression Results of snr vs. gt: snr = gt*slope + intercept\n\n");
printf("dc <atoms/cc*10e-17> slope intercept r-squared\n");
printf("-----------------------------------------------------------\n");
FILE *inFilePtr;
inFilePtr = fopen("noisedata.rtf","r");
char dc[5];
char gt[25];
char snr[25];
if ( inFilePtr == NULL )
printf("\nFile cannot be opened\n");
else
printf("\nContents of noisedata.rtf\n\n");
fscanf(inFilePtr, "%s", dc);
while ( !feof(inFilePtr) )
{
printf("%s\n", dc);
fscanf(inFilePtr, "%s", dc);
}
return 0;
}
do not know if i'm going in the right direction or not.